// import subsystem from "@/store/modules/adminSystem/data.js";

const context = require.context("@/router/subsystem", true, /index.js$/);
const regex = /\.\/(\w+)\/\w+.js/;
let subsystemRoutes = {};

// const addNamespaced = (key, router = []) => {
//   return router.map(route => {
//     let meta = route.meta;
//     if (subsystem.hasOwnProperty(key)) {
//       meta.title = subsystem[key].title + "|" + meta.title;
//     }
//     return {
//       ...route,
//       meta,
//       path: `/${key}_${route.path}`,
//       name: `${key}_${route.name}`
//     };
//   });
// };

context.keys().forEach(key => {
  let k = regex.exec(key)[1];
  let c = context(key).default;

  if (subsystemRoutes.hasOwnProperty(k)) {
    subsystemRoutes[k].push(...c);
  } else {
    subsystemRoutes[k] = c;
  }
});

export default subsystemRoutes;
